// 注册业务
const form = document.querySelector('form')
const btnRegister = document.querySelector('#btn-register')
btnRegister.addEventListener('click', async function () {
    const data = serialize(form, { hash: true, empty: true })
    const { username, password } = data
    if (username.length < 8 || username.length > 30) {
        return myAlter('用户名应在8~30位之间')
    }
    if (password.length < 6 || password.length > 30) {
        return myAlter('密码在6~30位之间')
    }
    const res = await axios.post('/register', data)
    myAlter(res.data.message)
    setTimeout(() => {
        location.href = 'login.html'
    }, 2000);
})